Xbasic

FILE.WATCH_CREATE Function

Syntax

V FILE.Watch_create(C Watchname , C Path , C flags , C Code)

Arguments

WatchnameCharacter

An arbitrary name assigned to the watch. You use this name in the FILE.WATCH_DESTROY().

PathCharacter

The folder that you want to monitor.

flagsCharacter

Flags - the flags that indicate which events you want to trap. The flags are:

Flag

Description

"F"

File renamed, added or deleted.

"D"

Directory renamed, added or deleted.

"A"

Attributes changed.

"L"

Length of a file changed.

"T"

Date/time stamp on a file changed.

"S"

Security setting changed.

CodeCharacter

A string containing the Xbasic code to be executed. E.g. " script_play(\"script_to_run\") ".

Description

Executes code on change of some aspect of a path changes (flags F= files renamed/add/delete D= sub-directory renamed/added/deleted A=Attributes changed L=Length of file(s) changed T=Time Changed S=File security changed R=recurse).

Discussion

The FILE.WATCH_CREATE() method allows you to monitor the activity in a particular folder on your computer, and automatically execute Xbasic code when:

  • a file is added or deleted in the folder
  • the size of a file in the folder is changed
  • the attributes of a file in the folder are changed
  • a sub-folder is added
  • the date/time stamp on a file changed
  • security settings on a file in the folder are changed

You can specify which of the events to react to.

Example

FILE.watch_create("temp_dir", "c:\temp", "F", "my_alert_function()")
? FILE.watch_enumerate()
= temp_dir c:\temp F
FILE.watch_destroy("temp_dir")

To find the name of the most recently created file use FILEFIND.GET().

See Also